﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Prism.Dialogs;
using Project1.Services;
using SourceGeneratorAttribute;
using System.Windows;

namespace Project1.ViewModels {
    public partial class Test1ViewModel(ICustomerStore _customerStore) : ObservableObject, IDialogAware {
        [ObservableProperty]
        private string _name;

        #region 实现IDialogAware接口
        public DialogCloseListener RequestClose { get; set; }

        public bool CanCloseDialog() => true;

        public void OnDialogClosed() { }

        public void OnDialogOpened(IDialogParameters parameters) {
            if (parameters.ContainsKey("title"))
                Title = parameters.GetValue<string>("title");
            if (parameters.ContainsKey("name"))
                Name = parameters.GetValue<string>("name");
        }

        public string Title { get; set; } = "温馨提示";
        #endregion


        [RelayCommand]
        private void ShowInfo() {
            _customerStore.GetAll().ForEach(i => {
                System.Windows.MessageBox.Show(i);
            });
        }
    }
}
